package com.geostart.constructionland.system.controller;

import com.geostar.constructionland.common.entity.response.AdjustAgrVersion;
import com.geostar.constructionland.common.entity.response.ExtJsAjaxResponse;
import com.geostart.constructionland.system.service.AdjustVersionFeignClient;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.validation.Valid;

/**
 * @author zhu jiacheng
 * @date 2020/7/22 10:27
 */
@Controller
@Api("平差版本分析")
public class AdjustVersionController {

    @Autowired
    private AdjustVersionFeignClient adjustVersionFeignClient;

    @GetMapping(path = "/adjust/version")
    public String index() {
        return "profile/adjust_version";
    }

    @ResponseBody
    @PostMapping(path = "/adjustVersion/add")
    public ExtJsAjaxResponse add(@Valid AdjustAgrVersion adjustAgrVersion) {
        return adjustVersionFeignClient.add(adjustAgrVersion);
    }

    @ResponseBody
    @PostMapping(path = "/adjustVersion/update")
    public ExtJsAjaxResponse update(@Valid AdjustAgrVersion adjustAgrVersion) {
        return adjustVersionFeignClient.update(adjustAgrVersion);
    }

    @ResponseBody
    @PostMapping(path = "/adjustVersion/delete")
    public ExtJsAjaxResponse delete(@RequestParam(value="id") String id) {
        return adjustVersionFeignClient.delete(id);
    }

    @ResponseBody
    @PostMapping(path = "/adjustVersion/list")
    public ExtJsAjaxResponse list(@RequestParam(value = "page") int pageNo, @RequestParam(value = "limit") int pageNum,@RequestParam(required=false) String query_param_adjust_version_name) {
        return adjustVersionFeignClient.list(pageNo, pageNum,query_param_adjust_version_name);
    }
}
